<?php

class Model_Provider extends Joob_Db_Table	{
	
	protected $key = "id";
	
	protected $db = "providers";
	
	public static function getAllProviders(){
		$provider = new Model_Provider();
		$rs =$provider->search('','id, name', 50, 'name ASC');
		$result = array();
		foreach ($rs as $row)	{
			$id = $row->id;
			$category = new Model_Category();
			$rs2 = $category->search("provider_id = $id", "id, name");
			$row->categories = $rs2;
			$result[] = $row;
		}
		return $result;
	}
}

?>